<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/js/vue.js"></script>
    <script src="/js/axios.js"></script>
</head>
<body>
<div id="d">
    <h1>欢迎你:{{username}}</h1>
    <table border="1" style="margin:auto; width:450px;">
        <tr>
            <th>编号</th>
            <th>名称</th>
            <th>价格</th>
        </tr>
        <tr v-for='p in products'>
            <td>{{p.id}}</td>
            <td>{{p.name}}</td>
            <td>{{p.price}}</td>
        </tr>
    </table>
</div>
<script>
    v=new Vue({
        el:'#d',
        data:{
            products:[],
            username:''
        },
        mounted(){
            axios.get('http://localhost/sal/product').then(ret=>{
                if(ret.data.rs){
                    this.products=ret.data.obj;
                    this.username=ret.data.extra;
                }
            });
        }
    })
</script>
</body>
</html>